package View;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JComponent;

public class JImageComponent extends JComponent {
	private Image backGroundImage;
	private int posX;
	private int posY;
	
	
	public JImageComponent(Image image,int x,int y){
		
		this.backGroundImage = image;
		this.posX=x;
		this.posY=y;
		Dimension size = new Dimension(image.getWidth(this),
		image.getHeight(this));
		setPreferredSize(size);
		setMinimumSize(size);
		setMaximumSize(size);
		setSize(size);

		
		
	}
	
	public JImageComponent(String imageName,int x,int y){
		
		this(new ImageIcon(imageName).getImage(), x, y);
		
	}
	
	 
	public void draw(Graphics g) {
		g.drawImage(backGroundImage, posX, posY, this);
		}

	public Image getBackGroundImage() {
		return backGroundImage;
	}

	public void setBackGroundImage(Image backGroundImage) {
		this.backGroundImage = backGroundImage;
	}

	public int getPosX() {
		return posX;
	}

	public void setPosX(int posX) {
		this.posX = posX;
	}

	public int getPosY() {
		return posY;
	}

	public void setPosY(int posY) {
		this.posY = posY;
	}
	
	
}